﻿<UserControl x:Class="DotNetSimaticDatabaseProtokollerConfigurationTool.Windows.EditProtocolDatasets"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Datasets="clr-namespace:DotNetSimaticDatabaseProtokollerLibrary.SettingsClasses.Datasets;assembly=JFK-ProtokollerLibrary"
             xmlns:DataTypes="clr-namespace:DotNetSiemensPLCToolBoxLibrary.DataTypes;assembly=DotNetSiemensPLCToolBoxLibrary"
             xmlns:DotNetSimaticDatabaseProtokollerLibrary="clr-namespace:DotNetSimaticDatabaseProtokollerLibrary;assembly=JFK-ProtokollerLibrary"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:WPF1="clr-namespace:DotNetSimaticDatabaseProtokollerConfigurationTool.WPF"
             xmlns:Converters="clr-namespace:JFKCommonLibrary.WPF.Converters;assembly=JFKCommonLibrary" Name="myControl"
             mc:Ignorable="d">

    <UserControl.Resources>
        <Converters:NullToFalseConverter x:Key="myNullToFalseConverter" />
        <WPF1:StringToPLCValueBoolConverter x:Key="myStringToPLCValueBoolConverter" />
		<Converters:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" />
        <Converters:ListIntToVisibilityConverter x:Key="VisConv0Visible" VisibleValue="0,4" />
        <Converters:IntToVisibilityConverter x:Key="VisConv1Visible" VisibleValue="1" />
        <Converters:IntToVisibilityConverter x:Key="VisConv2Visible" VisibleValue="2" />
        <Converters:IntToVisibilityConverter x:Key="VisConv3Visible" VisibleValue="3" />
        <Converters:IntToVisibilityConverter x:Key="VisConv5Visible" VisibleValue="5" />

        <Converters:IntToHiddenConverter x:Key="VisConv2Hidden" HiddenValue="2" />

        <ObjectDataProvider x:Key="dtrigger"
                            MethodName="GetValues"
                            ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="Datasets:DatasetTriggerType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <ObjectDataProvider x:Key="tagdatatype"
                            MethodName="GetValues"
                            ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="DataTypes:TagDataType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>

    <Grid Visibility="Visible">

        <DataGrid Name="grdDatasets"
                  Width="159"
                  Margin="12,10,0,45"
                  HorizontalAlignment="Left"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserReorderColumns="False"
                  CanUserResizeRows="False"
                  CanUserSortColumns="True"
                  ItemsSource="{Binding Datasets,
                                        Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}"
                  SelectionChanged="grdDatasets_SelectionChanged">
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="*"
                                        Header="Name"
                                        IsReadOnly="True"
                                        SortMemberPath="Name">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>

        <DataGrid Name="grdDatasetFields"
                  Margin="184,290,68,12"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserReorderColumns="False"
                  CanUserResizeRows="False"
                  CanUserSortColumns="False"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  ItemsSource="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.DatasetConfigRows}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv2Hidden}}">
            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridCell}">
                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridCell_PreviewMouseLeftButtonDown" />
                </Style>
            </DataGrid.Resources>
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Field"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseField">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseField}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding DatabaseField,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Fieldtype"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseFieldType">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseFieldType}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Margin="0"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Top"
                                      ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                                           AncestorType={x:Type UserControl}},
                                                            Path=GetGrdDatsetsObject.SelectedItem.Storage.DatabaseFieldTypes}"
                                      Padding="0"
                                      SelectedItem="{Binding DatabaseFieldType}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Padding="3,0,0,0" Text="{Binding}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Fieldsize"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseFieldSize">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseFieldSize}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding DatabaseFieldSize,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Connection"
                                        IsReadOnly="False"
                                        SortMemberPath="Connection">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Connection.Name}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Margin="0"
                                      HorizontalAlignment="Stretch"
                                      ItemsSource="{Binding Connections,
                                                            Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}"
                                      Padding="0"
                                      SelectedItem="{Binding Connection,
                                                             UpdateSourceTrigger=PropertyChanged}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Padding="3,0,0,0" Text="{Binding Name}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>

                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Value"
                                        IsReadOnly="False"
                                        SortMemberPath="PLCTag.S7FormatAddress">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.S7FormatAddress}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <DockPanel LastChildFill="True">
                                <Button Name="cmdSelectBitFromProjectInDataRowsList"
                                        HorizontalAlignment="Left"
                                        Click="cmdSelectBitFromProjectInDataRowsList_Click"
                                        Content="P"
                                        DockPanel.Dock="Right" />
                                <Button Name="cmdEditBitInDataRowsList"
                                        HorizontalAlignment="Left"
                                        Click="cmdEditBitInDataRowsList_Click"
                                        Content="..."
                                        DockPanel.Dock="Right" />
                                <TextBox Margin="0"
                                         Padding="0"
                                         Text="{Binding PLCTag.S7FormatAddress,
                                                        Mode=TwoWay}" />
                            </DockPanel>

                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Value Size"
                                        IsReadOnly="False"
                                        SortMemberPath="PLCTag.ArraySize">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <DockPanel LastChildFill="True">
                                <TextBox Margin="0"
                                         Padding="0"
                                         Text="{Binding PLCTag.ArraySize,
                                                        Mode=TwoWay}" />
                            </DockPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.ArraySize}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Value Type"
                                        IsReadOnly="False"
                                        SortMemberPath="PLCTag.TagDataType">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.TagDataType}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Margin="0"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Top"
                                      ItemsSource="{Binding Source={StaticResource tagdatatype}}"
                                      Padding="0"
                                      SelectedItem="{Binding PLCTag.TagDataType}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Padding="3,0,0,0" Text="{Binding}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="Auto"
                                        Header="Multiplier (0 = none)"
                                        IsReadOnly="False"
                                        SortMemberPath="Multiplier">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Multiplier}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding Multiplier,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="Auto"
                                        Header="Precision (0 = std)"
                                        IsReadOnly="False"
                                        SortMemberPath="Precision">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Precision}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding Precision,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="Auto"
                                        Header="Sub Field List (mostly not used)"
                                        IsReadOnly="False"
                                        SortMemberPath="StringSubFields">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding StringSubFields}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding StringSubFields,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>
        </DataGrid>

        <Button Name="cmdAddDatasetRow"
                Width="53"
                Height="23"
                Margin="186,239,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="cmdAddDatasetRow_Click"
                Content="Add"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Button Name="cmdRemoveDatasetRow"
                Width="53"
                Height="23"
                Margin="247,239,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Click="cmdRemoveDatasetRow_Click"
                Content="Remove"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Label Width="91"
               Height="26"
               Margin="183,76,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               VerticalContentAlignment="Center"
               Content="Trigger-Type"
               IsEnabled="{Binding ElementName=grdDatasets,
                                   Path=SelectedItem,
                                   Converter={StaticResource myNullToFalseConverter}}"
               Padding="0" />
        <ComboBox Name="cmbTriggerType"
                  Width="308"
                  Height="26"
                  Margin="266,76,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  VerticalContentAlignment="Center"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  ItemsSource="{Binding Source={StaticResource dtrigger}}"
                  SelectedIndex="1"
                  SelectedItem="{Binding ElementName=grdDatasets,
                                         Path=SelectedItem.Trigger}" />

        <GroupBox Width="443"
                  Height="73"
                  Margin="184,105,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Header="Tags-Handshake-Trigger"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv1Visible}}">
            <Grid>
                <Label Width="50"
                       Height="19"
                       Margin="1,3,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Padding="1">
                    Read Bit:
                </Label>
                <TextBox Width="141"
                         Height="19"
                         Margin="57,3,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         VerticalContentAlignment="Center"
                         BorderBrush="Black"
                         BorderThickness="1"
                         Padding="0"
                         Text="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.TriggerReadBit,
                                        Converter={StaticResource myStringToPLCValueBoolConverter}}" />
                <Button Name="cmdEditReadBit"
                        Width="28"
                        Height="19"
                        Margin="202,3,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Click="cmdEditReadBit_Click"
                        Content="..." />
                <Button Name="cmdSelectReadBitFromProject"
                        Width="28"
                        Height="19"
                        Margin="236,3,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Click="cmdSelectReadBitFromProject_Click"
                        Content="P" />

                <Label Width="50"
                       Height="19"
                       Margin="1,25,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Quitt Bit:"
                       Padding="1" />
                <TextBox Width="141"
                         Height="19"
                         Margin="57,25,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         VerticalContentAlignment="Center"
                         BorderBrush="Black"
                         BorderThickness="1"
                         Padding="0"
                         Text="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.TriggerQuittBit,
                                        Converter={StaticResource myStringToPLCValueBoolConverter}}" />
                <Button Name="cmdEditQuittBit"
                        Width="28"
                        Height="19"
                        Margin="202,25,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Click="cmdEditQuittBit_Click"
                        Content="..." />
                <Button Name="cmdSelectQuitBitFromProject"
                        Width="28"
                        Height="19"
                        Margin="236,25,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Click="cmdSelectQuitBitFromProject_Click"
                        Content="P" />
                <Rectangle Name="rectangle1"
                           Width="0"
                           Height="270"
                           Margin="-6,-112,0,0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Stroke="Black" />
                <Label Width="114"
                       Height="19"
                       Margin="283,3,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Trigger Connection:"
                       Padding="1" />

                <ComboBox Name="cmbTriggerConnection"
                          Width="114"
                          Height="23"
                          Margin="311,20,0,0"
                          HorizontalAlignment="Left"
                          VerticalAlignment="Top"
                          VerticalContentAlignment="Center"
                          IsEnabled="{Binding ElementName=grdDatasets,
                                              Path=SelectedItem,
                                              Converter={StaticResource myNullToFalseConverter}}"
                          ItemsSource="{Binding Connections,
                                                Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}"
                          SelectedItem="{Binding ElementName=grdDatasets,
                                                 Path=SelectedItem.TriggerConnection}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>
        </GroupBox>

        <GroupBox Width="443"
                  Height="73"
                  Margin="184,105,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Header="Tags-Handshake-Trigger"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv5Visible}}">
            <Grid>
                <Label Width="50"
                       Height="19"
                       Margin="1,3,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Padding="1">
                    Read Bit:
                </Label>
                <TextBox Width="141"
                         Height="19"
                         Margin="57,3,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         VerticalContentAlignment="Center"
                         BorderBrush="Black"
                         BorderThickness="1"
                         Padding="0"
                         Text="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.TriggerReadBit,
                                        Converter={StaticResource myStringToPLCValueBoolConverter}}" />
                <Button Name="cmdEditReadBit2"
                        Width="28"
                        Height="19"
                        Margin="202,3,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Click="cmdEditReadBit_Click"
                        Content="..." />
                <Button Name="cmdSelectReadBitFromProject2"
                        Width="28"
                        Height="19"
                        Margin="236,3,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Click="cmdSelectReadBitFromProject_Click"
                        Content="P" />

               
                <Rectangle Width="0"
                           Height="270"
                           Margin="-6,-112,0,0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Stroke="Black" />
                <Label Width="114"
                       Height="19"
                       Margin="283,3,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Trigger Connection:"
                       Padding="1" />

                <ComboBox Name="cmbTriggerConnection2"
                          Width="114"
                          Height="23"
                          Margin="311,20,0,0"
                          HorizontalAlignment="Left"
                          VerticalAlignment="Top"
                          VerticalContentAlignment="Center"
                          IsEnabled="{Binding ElementName=grdDatasets,
                                              Path=SelectedItem,
                                              Converter={StaticResource myNullToFalseConverter}}"
                          ItemsSource="{Binding Connections,
                                                Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}"
                          SelectedItem="{Binding ElementName=grdDatasets,
                                                 Path=SelectedItem.TriggerConnection}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>
        </GroupBox>
        
        <GroupBox Width="285"
                  Height="73"
                  Margin="184,105,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Header="Time-Trigger"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv0Visible}}">
            <Grid>
                <Label Width="109"
                       Height="19"
                       Margin="1,3,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Trigger Interval:"
                       Padding="1" />
                <TextBox Width="122"
                         Height="26"
                         Margin="145,18,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         BorderBrush="Black"
                         IsEnabled="{Binding ElementName=grdDatasets,
                                             Path=SelectedItem,
                                             Converter={StaticResource myNullToFalseConverter}}"
                         Text="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.TriggerTimeSpan}" />
                <Label Width="94"
                       Height="19"
                       Margin="16,25,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="(hh:mm:ss.ms)"
                       Padding="1" />
            </Grid>
        </GroupBox>

        <GroupBox Width="560"
                  Height="99"
                  Margin="184,105,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Header="Quartz-Trigger"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv3Visible}}">
            <Grid>
                <Label Width="109"
                       Height="19"
                       Margin="1,3,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Cron Tabelle"
                       Padding="1" />
                <TextBox Width="211"
                         Height="50"
                         Margin="6,20,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         AcceptsReturn="True"
                         BorderBrush="Black"
                         IsEnabled="{Binding ElementName=grdDatasets,
                                             Path=SelectedItem,
                                             Converter={StaticResource myNullToFalseConverter}}"
                         Text="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.CronTab}"
                         TextWrapping="Wrap"
                         VerticalScrollBarVisibility="Visible" />
                <TextBlock Width="301"
                           Height="58"
                           Margin="223,11,0,0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Text="Trigger anhand eine Cron Tabelle. Infos was man eingeben kann gibts hier:"
                           TextWrapping="Wrap" />


                <TextBlock Margin="223,54,24,6">
                    <Hyperlink NavigateUri="http://quartznet.sourceforge.net/tutorial/lesson_6.html" WPF1:HyperlinkUtility.LaunchDefaultBrowser="True">http://quartznet.sourceforge.net/tutorial/lesson_6.html</Hyperlink>
                </TextBlock>
            </Grid>
        </GroupBox>

        <TextBox Name="txtTableName"
                 Width="179"
                 Height="26"
                 Margin="266,12,0,0"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Top"
                 BorderBrush="Black"
                 IsEnabled="{Binding ElementName=grdDatasets,
                                     Path=SelectedItem,
                                     Converter={StaticResource myNullToFalseConverter}}"
                 KeyUp="txt_Enter_ValueUpdater"
                 Text="{Binding ElementName=grdDatasets,
                                Path=SelectedItem.Name}" />
        <Label Width="83"
               Height="26"
               Margin="183,12,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               VerticalContentAlignment="Center"
               Content="Table (Name)"
               IsEnabled="{Binding ElementName=grdDatasets,
                                   Path=SelectedItem,
                                   Converter={StaticResource myNullToFalseConverter}}"
               Padding="0" />
        <Label Width="55"
               Height="26"
               Margin="184,44,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               VerticalContentAlignment="Center"
               Content="Storage"
               IsEnabled="{Binding ElementName=grdDatasets,
                                   Path=SelectedItem,
                                   Converter={StaticResource myNullToFalseConverter}}"
               Padding="0" />
        <ComboBox Name="cmbStorage"
                  Width="179"
                  Height="26"
                  Margin="266,44,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  VerticalContentAlignment="Center"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  ItemsSource="{Binding Storages,
                                        Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}"
                  SelectedItem="{Binding ElementName=grdDatasets,
                                         Path=SelectedItem.Storage}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <Button Name="cmdAddDataset"
                Width="53"
                Height="23"
                Margin="12,0,0,12"
                HorizontalAlignment="Left"
                VerticalAlignment="Bottom"
                Click="cmdAddDataset_Click"
                Content="Add" />
        <Button Name="cmdRemoveDataset"
                Width="53"
                Height="23"
                Margin="118,0,0,12"
                HorizontalAlignment="Left"
                VerticalAlignment="Bottom"
                Click="cmdRemoveDataset_Click"
                Content="Remove" />
        <Rectangle Name="rectangle2"
                   Width="2"
                   Margin="176,5,0,5"
                   HorizontalAlignment="Left"
                   Fill="Black"
                   Stroke="Black" />
        <Button Name="cmdCopyDataset"
                Width="41"
                Height="23"
                Margin="71,0,0,12"
                HorizontalAlignment="Left"
                VerticalAlignment="Bottom"
                Click="cmdCopyDataset_Click"
                Content="Copy" />
        <GroupBox Width="390"
                  Height="73"
                  Margin="184,105,0,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Header="Connection"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv2Visible}}">
            <Grid>
                <Rectangle Name="rectangle3"
                           Width="0"
                           Height="270"
                           Margin="-6,-112,0,0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Stroke="Black" />
                <Label Width="114"
                       Height="19"
                       Margin="76,6,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Content="Trigger Connection:"
                       Padding="1" />
                <ComboBox Name="comboBox1"
                          Width="114"
                          Height="23"
                          Margin="104,23,0,0"
                          HorizontalAlignment="Left"
                          VerticalAlignment="Top"
                          VerticalContentAlignment="Center"
                          IsEnabled="{Binding ElementName=grdDatasets,
                                              Path=SelectedItem,
                                              Converter={StaticResource myNullToFalseConverter}}"
                          ItemsSource="{Binding Connections,
                                                Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}"
                          SelectedItem="{Binding ElementName=grdDatasets,
                                                 Path=SelectedItem.TriggerConnection}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>
        </GroupBox>
        <DataGrid Name="grdDatasetFieldsEthernet"
                  Margin="184,290,68,12"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserReorderColumns="False"
                  CanUserResizeRows="False"
                  CanUserSortColumns="False"
                  IsEnabled="{Binding ElementName=grdDatasets,
                                      Path=SelectedItem,
                                      Converter={StaticResource myNullToFalseConverter}}"
                  ItemsSource="{Binding ElementName=grdDatasets,
                                        Path=SelectedItem.DatasetConfigRows}"
                  Visibility="{Binding ElementName=cmbTriggerType,
                                       Path=SelectedItem,
                                       Converter={StaticResource VisConv2Visible}}">
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Field"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseField">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding DatabaseField,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseField}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Fieldtype"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseFieldType">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Margin="0"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Top"
                                      ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                                           AncestorType={x:Type UserControl}},
                                                            Path=GetGrdDatsetsObject.SelectedItem.Storage.DatabaseFieldTypes}"
                                      Padding="0"
                                      SelectedItem="{Binding DatabaseFieldType}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Padding="3,0,0,0" Text="{Binding}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseFieldType}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="Database-Fieldsize"
                                        IsReadOnly="False"
                                        SortMemberPath="DatabaseFieldSize">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding DatabaseFieldSize,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DatabaseFieldSize}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Value Size"
                                        IsReadOnly="False"
                                        SortMemberPath="PLCTag.ArraySize">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <DockPanel LastChildFill="True">
                                <TextBox Margin="0"
                                         Padding="0"
                                         Text="{Binding PLCTag.ArraySize,
                                                        Mode=TwoWay}" />
                            </DockPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.ArraySize}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Value Type"
                                        IsReadOnly="False"
                                        SortMemberPath="PLCTag.TagDataType">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Margin="0"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Top"
                                      ItemsSource="{Binding Source={StaticResource tagdatatype}}"
                                      Padding="0"
                                      SelectedItem="{Binding PLCTag.TagDataType}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Padding="3,0,0,0" Text="{Binding}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.TagDataType}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="Auto"
                                        Header="PLC-Read Byte Size"
                                        IsReadOnly="True"
                                        SortMemberPath="PLCTag.TagDataType">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding PLCTag.ReadByteSize}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="Auto"
                                        Header="Multiplier (0 = none)"
                                        IsReadOnly="False"
                                        SortMemberPath="Multiplier">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Multiplier}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding Multiplier,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="Auto"
                                        Header="Precision (0 = std)"
                                        IsReadOnly="False"
                                        SortMemberPath="Precision">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Precision}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding Precision,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="Auto"
                                        Header="Sub Field List (mostly not used)"
                                        IsReadOnly="False"
                                        SortMemberPath="StringSubFields">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding StringSubFields}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0"
                                     Padding="0"
                                     Text="{Binding StringSubFields,
                                                    Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>
            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridCell}">
                    <EventSetter Event="UIElement.PreviewMouseLeftButtonDown" Handler="DataGridCell_PreviewMouseLeftButtonDown" />
                </Style>
            </DataGrid.Resources>
        </DataGrid>
        <Label Width="214"
               Height="26"
               Margin="462,12,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               VerticalContentAlignment="Center"
               Content="Write PC DateTime to following Field"
               IsEnabled="{Binding ElementName=grdDatasets,
                                   Path=SelectedItem,
                                   Converter={StaticResource myNullToFalseConverter}}"
               Padding="0"
               ToolTip="If this is Empty, PC Date is not saved to database!" />
        <TextBox Width="179"
                 Height="26"
                 Margin="671,12,0,0"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Top"
                 BorderBrush="Black"
                 IsEnabled="{Binding ElementName=grdDatasets,
                                     Path=SelectedItem,
                                     Converter={StaticResource myNullToFalseConverter}}"
                 Text="{Binding ElementName=grdDatasets,
                                Path=SelectedItem.DateTimeDatabaseField}" />
        <TextBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="179"
                 Height="26"
                 Margin="671,38,0,0"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Top"
                 BorderBrush="Black"
                 IsEnabled="{Binding ElementName=grdDatasets,
                                     Path=SelectedItem,
                                     Converter={StaticResource myNullToFalseConverter}}"
                 Text="{Binding ElementName=grdDatasets,
                                Path=SelectedItem.DateTimeDatabaseFieldFormat}" />
        <Label Name="lblSize"
               Width="93"
               Height="18"
               Margin="0,355,13,0"
               HorizontalAlignment="Right"
               VerticalAlignment="Top"
               HorizontalContentAlignment="Right"
               Padding="0" RenderTransformOrigin="1.037,1.778" />
        <Label Width="214"
               Height="26"
               Margin="186,209,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               VerticalContentAlignment="Center"
               Content="Max Datasets"
               IsEnabled="{Binding ElementName=grdDatasets,
                                   Path=SelectedItem,
                                   Converter={StaticResource myNullToFalseConverter}}"
               Padding="0"
               ToolTip="If this is Empty, PC Date is not saved to database!" />
        <TextBox Width="179"
                 Height="26"
                 Margin="266,209,0,0"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Top"
                 BorderBrush="Black"
                 IsEnabled="{Binding ElementName=grdDatasets,
                                     Path=SelectedItem,
                                     Converter={StaticResource myNullToFalseConverter}}"
                 Text="{Binding ElementName=grdDatasets,
                                Path=SelectedItem.MaxDatasets}" />
        <Label Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="176"
               Height="26"
               Margin="491,39,0,0"
               HorizontalAlignment="Left"
               VerticalAlignment="Top"
               VerticalContentAlignment="Center"
               Content="DateTime Format (for CSV etc.)"
               IsEnabled="{Binding ElementName=grdDatasets,
                                   Path=SelectedItem,
                                   Converter={StaticResource myNullToFalseConverter}}"
               Padding="0"
               ToolTip="If this is Empty, PC Date is not saved to database!" />
        <Button Name="cmdAddDatasetRowsFromProjectFile"
		Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}"
                Width="129"
                Height="23"
                Margin="0,239,68,0"
                HorizontalAlignment="Right"
                VerticalAlignment="Top"
                Click="cmdAddDatasetRowsFromProjectFile_Click"
                Content="Multi Add"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Button Name="cmdMoveUp"
                Width="50"
                Height="23"
                Margin="0,318,13,0"
                HorizontalAlignment="Right"
                VerticalAlignment="Top"
                Click="cmdMoveUp_Click"
                Content="^"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Button Name="cmdMoveDown"
                Width="50"
                Height="23"
                Margin="0,0,13,40"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Click="cmdMoveDown_Click"
                Content="v"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Button Name="cmdMoveToFirst"
                Width="50"
                Height="23"
                Margin="0,290,13,0"
                HorizontalAlignment="Right"
                VerticalAlignment="Top"
                Click="cmdMoveToFirst_Click"
                Content="first"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <Button Name="cmdMoveToLast"
                Width="50"
                Height="23"
                Margin="0,0,13,12"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Click="cmdMoveToLast_Click"
                Content="last"
                IsEnabled="{Binding ElementName=grdDatasets,
                                    Path=SelectedItem,
                                    Converter={StaticResource myNullToFalseConverter}}" />
        <CheckBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Content="Use for all PLC-Tags the following connection:" Height="16" HorizontalAlignment="Left" Margin="671,140,0,0" Name="chkUseSameConnection" VerticalAlignment="Top" IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}"/>
        <ComboBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="119" Margin="671,165,0,0" Name="cmb_UseSameConnection"
                  IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}" 
                  ItemsSource="{Binding Connections, Source={x:Static DotNetSimaticDatabaseProtokollerLibrary:ProtokollerConfiguration.ActualConfigInstance}}">
                  <!--SelectedItem="{Binding ElementName=grdDatasets, Path=SelectedItem.Connections}">-->
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <Button Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Content="Go" Height="23" HorizontalAlignment="Left" IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}" Margin="797,165,0,0" Name="btn_UseSameConnection" VerticalAlignment="Top" Width="53" Click="btn_UseSameConnection_Click" />
        <CheckBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Content="Use the following Databasetype for PLC-Datatype" Height="16" HorizontalAlignment="Left" IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}" Margin="671,199,0,0" Name="chkConvertTypes" VerticalAlignment="Top" />
        <ComboBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Height="23" HorizontalAlignment="Left" IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}" 
                  ItemsSource="{Binding Source={StaticResource tagdatatype}}"
                    Padding="0"
                    SelectedItem="{Binding PLCTag.TagDataType}"
                    Margin="671,221,0,0" Name="cmb_PLCType" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="65">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <ComboBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Height="23" HorizontalAlignment="Left" IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}" Margin="867,221,0,0" Name="cmb_DBType" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="65"
                  ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=GetGrdDatsetsObject.SelectedItem.Storage.DatabaseFieldTypes}" SelectedItem="{Binding DatabaseFieldType}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <Button Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Content="PLC-Type -&gt; Database" Height="23" HorizontalAlignment="Left" Margin="742,221,0,0" Name="btn_ConvertTypes" VerticalAlignment="Top" Width="119" IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}" Click="button1_Click" />

        <CheckBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Content="Use float instead of converting to Text if Multiplier is used" Height="16" Margin="0,269,68,0" Name="cb_Multiplier" VerticalAlignment="Top"
                  IsEnabled="{Binding ElementName=grdDatasets, Path=SelectedItem, Converter={StaticResource myNullToFalseConverter}}"
                  IsChecked="{Binding ElementName=grdDatasets, Path=SelectedItem.UseFloatIfMultiplierIsUsed}" HorizontalAlignment="Right" Width="392"/>
        <CheckBox Content="Expert Mode" Height="16" Margin="186,269,0,0" x:Name="cb_ExpertMode" VerticalAlignment="Top"
        	IsEnabled="{Binding SelectedItem, Converter={StaticResource myNullToFalseConverter}, ElementName=grdDatasets}"
        	HorizontalAlignment="Left" Width="114"/>
        <CheckBox IsChecked="{Binding SelectedItem.UseDbUpdateNoInsert, ElementName=grdDatasets}" Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Content="Use Insert instead of Update (on databases)" Height="16" HorizontalAlignment="Left" IsEnabled="{Binding SelectedItem, Converter={StaticResource myNullToFalseConverter}, ElementName=grdDatasets}" Margin="671,70,0,0" x:Name="chkConvertTypes_Copy" VerticalAlignment="Top" />
        <TextBox Visibility="{Binding IsChecked, Converter={StaticResource boolToVisibilityConverter}, ElementName=cb_ExpertMode}" Width="179"
        	Height="26"
        	Margin="671,91,0,0"
        	HorizontalAlignment="Left"
        	VerticalAlignment="Top"
        	BorderBrush="Black"
        	IsEnabled="{Binding SelectedItem, Converter={StaticResource myNullToFalseConverter}, ElementName=grdDatasets}"
        	Text="{Binding SelectedItem.UpdateWhereClause, ElementName=grdDatasets}" ToolTip="Where Clause for Update" />
    </Grid>
</UserControl>
